home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog5.arj / MESSAGE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  2.0 KB  |  84 lines

  1. { message.pas -- A menu with messages }
  2.  
  3. program Message;
  4.  
  5. {$R menu.res}
  6.  
  7. uses WinTypes, WinProcs, WObjects, Strings;
  8.  
  9. const
  10.  
  11.   id_Menu     = 100;    {- Menu resource ID }
  12.   cm_FileNew  = 101;    {- Command resource IDs }
  13.   cm_FileOpen = 102;
  14.   cm_FileExit = 103;
  15.  
  16. type
  17.  
  18.   MsgApplication = object(TApplication)
  19.     procedure InitMainWindow; virtual;
  20.   end;
  21.  
  22.   PMsgWindow = ^MsgWindow;
  23.   MsgWindow = object(TWindow)
  24.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  25.     procedure CMFileNew(var Msg: TMessage);
  26.       virtual cm_First + cm_FileNew;
  27.     procedure CMFileOpen(var Msg: TMessage);
  28.       virtual cm_First + cm_FileOpen;
  29.     procedure CMFileExit(var Msg: TMessage);
  30.       virtual cm_First + cm_FileExit;
  31.   end;
  32.  
  33. { MsgApplication }
  34.  
  35. {- Initialize the application's window }
  36. procedure MsgApplication.InitMainWindow;
  37. begin
  38.   MainWindow := New(PMsgWindow, Init(nil, 'Message Menu'))
  39. end;
  40.  
  41. { MsgWindow }
  42.  
  43. {- Initialize the application's window object }
  44. constructor MsgWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  45. begin
  46.   TWindow.Init(AParent, ATitle);
  47.   Attr.Menu := LoadMenu(HInstance, PChar(id_Menu))
  48. end;
  49.  
  50. {- Process File:New command }
  51. procedure MsgWindow.CMFileNew(var Msg: TMessage);
  52. begin
  53.   MessageBox(HWindow, 'New command', 'Message Box', mb_Ok)
  54. end;
  55.  
  56. {- Process File:Open command }
  57. procedure MsgWindow.CMFileOpen(var Msg: TMessage);
  58. begin
  59.   MessageBox(HWindow, 'Open command', 'Message Box', mb_Ok)
  60. end;
  61.  
  62. {- Process File:Exit command }
  63. procedure MsgWindow.CMFileExit(var Msg: TMessage);
  64. begin
  65.   MessageBox(HWindow, 'Exit command', 'Message Box', mb_Ok);
  66.   CloseWindow
  67. end;
  68.  
  69. var
  70.  
  71.   MsgApp: MsgApplication;
  72.  
  73. begin
  74.   MsgApp.Init('MsgApp');
  75.   MsgApp.Run;
  76.   MsgApp.Done
  77. end.
  78.  
  79.  
  80. { --------------------------------------------------------------
  81.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  82.   Revision 1.00    Date: 1/11/91
  83.   ------------------------------------------------------------- }
  84.